<meta charset="utf-8">
<div class="window" >
	<div class="window-caption fg-white bg-cyan">
		<span class="window-caption-icon"><span class="mif-windows"></span></span>
		<span class="window-caption-title"><span>留言板</span></span> <span
			class="btn-close" onclick="closeWindow()"></span>
	</div>
	<div class="window-content">
		<form action="send" method="post" >
			<div class="input-control textarea full-size">
				<textarea id="content" disabled > 留言什么的算了吧... </textarea>
			</div>
			<input disabled type="submit" value="发送留言">
		</form>

		<div id="comments-container" class="sub-header no-float">
			<div style="margin:100px auto; width: 150px;">
				<span class="icon mif-spinner5 mif-2x mif-ani-pulse fg-grayLight"></span>
				<span class="fg-grayLight">加载中...</span>
			</div>
		</div>
	</div>


	<script>
		var currentSec = 0;
		var count = 0;
		$("#comments-container").load("1/comments.do");
		$("form").submit(function(){

			check();

			$.post("send.do",{ content:$("#content").val()},function(data){
				if(data == 1){
					$.Notify({
				        caption: '留言成功',
				        content: '谢谢您的支持...',
				        type: 'success'
				      });
					$("#comments-container").load("1/comments.do");
					$("#content").val("");
				}else if(data == 2){
					$.Notify({
				        caption: '留言成功',
				        content: '谢谢您的支持，留言将在管理员审核后显示！',
				        type: 'success'
				      });
					$("#comments-container").load("1/comments.do");
					$("#content").val("");
				}else{
					$.Notify({
				        caption: '系统繁忙',
				        content: '请您稍后再试...',
				        type: 'warning'
				      });
				}
			})
			return false;
		});

		function check(){
			if(getCookie("ban")){
				alert("您刷的太多了 0.0 服务器承受不了！");
				return false;
			}

			if(new Date().getTime() - currentSec < 5000){
				$.Notify({
			        caption: '留言失败',
			        content: '您的速度太快了.请慢慢来。',
			        type: 'warning'
			      });
				count++;
				if(count > 20){
					setCookie("ban", "ban", 1);
				}
				return false;
			}
			count = 0;
			currentSec = new Date().getTime();
		}
	</script>
</div>
